﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CCF20Model.FaultHandler
{
    class ProcessUrgentHandler2 : FaultHandlerBase
    {
        public ProcessUrgentHandler2(IFaultHandler faultHandler)
        {
            this.ccf20Ent = faultHandler.ccf20Ent;
            this.PreviousHandler = faultHandler;
            this.MyVehicle = faultHandler.MyVehicle;
            this.MyFault = faultHandler.MyFault;
        }

        public override void ProcessRequest()
        {
            LoggerHelper.LogZICDebug("[故障分析]需要处理的撞车");
            MyVehicle.LatestActiveTime = DateTime.Now;
            MyVehicle.IsUrgent = true;
            MyVehicle.PreviousContactResult = MyVehicle.LastContactResult;
            MyVehicle.LastContactResult =WiseLink.RDS.Resource.WiseLinkRDSStatus.Contact_NotContactYet;
            MyFault.CloseReason = "需要处理";
            SendShortMessage("事故", "事故车车主提醒模板");
            //SendGPRSMessage("事故", "事故车车主提醒模板");
            AddReminderQueue();
            IFaultHandler nextHandler = new CompleteFaultHandler(this);
            nextHandler.ProcessRequest();

        }
        private void AddReminderQueue()
        {
            smsModel = GetSMSModel();
            foreach (RemindList reminder in ccf20Ent.RemindLists)
            {
                UrgentSMSQueue smsQueue = new UrgentSMSQueue();
                smsQueue.IsActive = true;
                smsQueue.VehicleID = MyVehicle.VehicleID;
                smsQueue.ReceiverName = reminder.Name;
                smsQueue.ReceiverMobile = reminder.FirstMobile;
                smsQueue.SendTime = DateTime.Now.AddSeconds((int)reminder.TimeGap);
                smsQueue.Content = SMSModel.GetSMSContent("事故", "事故车超出响应", MyVehicle,reminder.Name);
                if (smsQueue.Content != string.Empty)
                {
                    ccf20Ent.UrgentSMSQueues.AddObject(smsQueue);
                    LoggerHelper.LogZICDebug(string.Format("[撞车提醒]产生定时提醒短信 {0}-{1}  内容={2}",
                                                                smsQueue.SendTime.ToShortDateString(),
                                                                smsQueue.SendTime.ToLongTimeString(),
                                                                smsQueue.Content));
                }
            }
        }

    }
}
